'''
    ST-ResNet: Deep Spatio-temporal Residual Networks
'''

from __future__ import print_function
from keras.layers import (
    Input,
    Activation,
    merge,
    Dense,
    Reshape
)
from keras.layers.convolutional import Convolution2D
from keras.layers.normalization import BatchNormalization
from keras.models import Model
#from keras.utils.visualize_util import plot


def _shortcut(input, residual):
    return merge([input, residual], mode='sum')


def _bn_relu_conv(nb_filter, nb_row, nb_col, subsample=(1, 1), bn=False):
    def f(input):
        if bn:
            input = BatchNormalization(mode=0, axis=1)(input)
        activation = Activation('relu')(input)
        return Convolution2D(nb_filter=nb_filter, nb_row=nb_row, nb_col=nb_col, subsample=subsample, border_mode="same")(activation)
    return f


def _residual_unit(nb_filter, init_subsample=(1, 1)):
    def f(input):
        residual = _bn_relu_conv(nb_filter, 3, 3)(input)
        residual = _bn_relu_conv(nb_filter, 3, 3)(residual)
        return _shortcut(input, residual)
    return f


def ResUnits(residual_unit, nb_filter, repetations=1):
    def f(input):
        for i in range(repetations):
            init_subsample = (1, 1)
            input = residual_unit(nb_filter=nb_filter,
                                  init_subsample=init_subsample)(input)
        return input
    return f


def stresnet(c_conf=(4, 1, 35, 12), p_conf=(4, 1, 35, 12), external_dim=9, nb_residual_unit=4):
    '''   针对时空数据定义时空残差网络
    C - Temporal Closeness
    P - Period
    T - Trend
    conf = (len_seq, nb_flow, map_height, map_width)
    external_dim
    '''
    # main input
    main_inputs = []
    outputs = []
    ####################################针对于
    for conf in [c_conf, p_conf]:
        if conf is not None:
            #因为conf是四维的，所以这些东西都可以对应放置进去， 把序列长度、流入流出量、图的高宽都放进去
            #这里因为是一个个添加的，所以会将所有的输入序列全放进去，shape是所代表的形状，提前制定好了形状
            len_seq, nb_flow, map_height, map_width = conf
            input = Input(shape=(nb_flow * len_seq, map_height, map_width))
            main_inputs.append(input)
            # Conv1    定义好卷积层  顺带后面添加了残差单元
            conv1 = Convolution2D(
                nb_filter=64, nb_row=3, nb_col=3, border_mode="same")(input)
            # [nb_residual_unit] Residual Units
            residual_output = ResUnits(_residual_unit, nb_filter=64,
                              repetations=nb_residual_unit)(conv1)
            # Conv2 第一第二个卷积层
            activation = Activation('relu')(residual_output)
            conv2 = Convolution2D(
                nb_filter=nb_flow, nb_row=3, nb_col=3, border_mode="same")(activation)
            outputs.append(conv2)


    # parameter-matrix-based fusion
    if len(outputs) == 1:
        main_output = outputs[0]
    else:
        from deepst.models.iLayer import iLayer
        new_outputs = []
        for output in outputs:
            new_outputs.append(iLayer()(output))
        #定义融合模式
        main_output = merge(new_outputs, mode='sum')

    # fusing with external component     现在考虑对额外因素信息的引入
    if external_dim != None and external_dim > 0:
        # external input   将外部因素融入时，定义了一个全连接层，并进行了维度的转换
        external_input = Input(shape=(external_dim,))
        main_inputs.append(external_input)
        embedding = Dense(output_dim=10)(external_input)
        embedding = Activation('relu')(embedding)
        h1 = Dense(output_dim=nb_flow * map_height * map_width)(embedding)
        activation = Activation('relu')(h1)
        external_output = Reshape((nb_flow, map_height, map_width))(activation)
        #最终的输出是通过主融合输出和外部因素的输出的  加和在一起的
        main_output = merge([main_output, external_output], mode='sum')
    else:
        print('external_dim:', external_dim)

    main_output = Activation('tanh')(main_output)
    model = Model(input=main_inputs, output=main_output)
    return model

if __name__ == '__main__':
    model = stresnet(external_dim=9, nb_residual_unit=8)
    #plot(model, to_file='ST-ResNet.png', show_shapes=True)
    model.summary()


'''
打印信息为：
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_1 (InputLayer)             (None, 6, 32, 32)     0                                            
____________________________________________________________________________________________________
input_2 (InputLayer)             (None, 6, 32, 32)     0                                            
____________________________________________________________________________________________________
input_3 (InputLayer)             (None, 6, 32, 32)     0                                            
____________________________________________________________________________________________________
conv2d_1 (Conv2D)                (None, 64, 32, 32)    3520                                         
____________________________________________________________________________________________________
conv2d_27 (Conv2D)               (None, 64, 32, 32)    3520                                         
____________________________________________________________________________________________________
conv2d_53 (Conv2D)               (None, 64, 32, 32)    3520                                         
____________________________________________________________________________________________________
activation_1 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_26 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_51 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_2 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_28 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_54 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_2 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_27 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_52 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_3 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_29 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_55 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_1 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_13 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_25 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_3 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_28 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_53 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_4 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_30 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_56 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_4 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_29 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_54 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_5 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_31 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_57 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_2 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_14 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_26 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_5 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_30 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_55 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_6 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_32 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_58 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_6 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_31 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_56 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_7 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_33 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_59 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_3 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_15 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_27 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_7 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_32 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_57 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_8 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_34 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_60 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_8 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_33 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_58 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_9 (Conv2D)                (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_35 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_61 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_4 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_16 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_28 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_9 (Activation)        (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_34 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_59 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_10 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_36 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_62 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_10 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_35 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_60 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_11 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_37 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_63 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_5 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_17 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_29 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_11 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_36 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_61 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_12 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_38 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_64 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_12 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_37 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_62 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_13 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_39 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_65 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_6 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_18 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_30 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_13 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_38 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_63 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_14 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_40 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_66 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_14 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_39 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_64 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_15 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_41 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_67 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_7 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_19 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_31 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_15 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_40 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_65 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_16 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_42 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_68 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_16 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_41 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_66 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_17 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_43 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_69 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_8 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_20 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_32 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_17 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_42 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_67 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_18 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_44 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_70 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_18 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_43 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_68 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_19 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_45 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_71 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_9 (Merge)                  (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_21 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_33 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_19 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_44 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_69 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_20 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_46 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_72 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_20 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_45 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_70 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_21 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_47 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_73 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_10 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_22 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_34 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_21 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_46 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_71 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_22 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_48 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_74 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_22 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_47 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_72 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_23 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_49 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_75 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
merge_11 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_23 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_35 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_23 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_48 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_73 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_24 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_50 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_76 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
activation_24 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_49 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_74 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
conv2d_25 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_51 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
conv2d_77 (Conv2D)               (None, 64, 32, 32)    36928                                        
____________________________________________________________________________________________________
input_4 (InputLayer)             (None, 28)            0                                            
____________________________________________________________________________________________________
merge_12 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_24 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
merge_36 (Merge)                 (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
dense_1 (Dense)                  (None, 10)            290                                          
____________________________________________________________________________________________________
activation_25 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_50 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_75 (Activation)       (None, 64, 32, 32)    0                                            
____________________________________________________________________________________________________
activation_76 (Activation)       (None, 10)            0                                            
____________________________________________________________________________________________________
conv2d_26 (Conv2D)               (None, 2, 32, 32)     1154                                         
____________________________________________________________________________________________________
conv2d_52 (Conv2D)               (None, 2, 32, 32)     1154                                         
____________________________________________________________________________________________________
conv2d_78 (Conv2D)               (None, 2, 32, 32)     1154                                         
____________________________________________________________________________________________________
dense_2 (Dense)                  (None, 2048)          22528                                        
____________________________________________________________________________________________________
i_layer_1 (iLayer)               (None, 2, 32, 32)     2048                                         
____________________________________________________________________________________________________
i_layer_2 (iLayer)               (None, 2, 32, 32)     2048                                         
____________________________________________________________________________________________________
i_layer_3 (iLayer)               (None, 2, 32, 32)     2048                                         
____________________________________________________________________________________________________
activation_77 (Activation)       (None, 2048)          0                                            
____________________________________________________________________________________________________
merge_37 (Merge)                 (None, 2, 32, 32)     0                                            
____________________________________________________________________________________________________
reshape_1 (Reshape)              (None, 2, 32, 32)     0                                            
____________________________________________________________________________________________________
merge_38 (Merge)                 (None, 2, 32, 32)     0                                            
____________________________________________________________________________________________________
activation_78 (Activation)       (None, 2, 32, 32)     0                                            
====================================================================================================
Total params: 2,701,800.0
Trainable params: 2,701,800.0
Non-trainable params: 0.0

'''